import java.util.Stack;

public class Match {
    public static void main2(String[] args) {
        String a = "q";
        String b = "q";
        if(a == b){
            System.out.println("true");
        }else {
            System.out.println("false");
        }
    }
    public static void main(String[] args) {
        String[] str = {"{","{", "[", "(", ")", "]", "}"};
        Stack<String> stack = new Stack<>();
        for (int i = 0; i < str.length; i++) {
            if (str[i].equals("{") || str[i].equals("[") || str[i].equals("(")) {
                stack.push(str[i]);
            } else {
                if (stack.empty()){
                    System.out.println("栈为空");
                    return;
                }
                String tmp = new String();
                if (str[i].equals("}")){
                    tmp = "{";
                }
                if (str[i].equals("]")){
                    tmp = "[";
                }
                if (str[i].equals(")")){
                    tmp = "(";
                }
                String ret = stack.pop();
                if (!ret.equals(tmp)) {
                    System.out.println("不匹配");
                    return;
                }
            }
        }
        if(stack.empty()){
            System.out.println("匹配");
        }else {
            System.out.println("不匹配");
        }
    }
}
